home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / mipsABI / examples / after / index2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  995 b   |  61 lines

  1. /*
  2.  * illustrate the use of memory and string routines
  3.  *
  4.  * Alternative to index.c:
  5.  * If _ABI_SOURCE is defined, change the code
  6.  */
  7.  
  8. #ifdef _ABI_SOURCE
  9. #include <string.h>
  10. #define ANSI_STRING
  11. #else
  12. #include <strings.h>
  13. #endif
  14. #ifdef  _ABI_SOURCE
  15. #include <memory.h>
  16. #endif
  17. #include <stdio.h>
  18.  
  19. #ifndef _ABI_SOURCE
  20. extern int bcmp ();
  21. extern void bzero ();
  22. extern void bcopy ();
  23. #endif
  24.  
  25.  
  26. #define BUFFER 256
  27. char *string = "this is a test";
  28. char buf[BUFFER];
  29.  
  30. main ()
  31. {
  32.     int rv;
  33.     char *cp;
  34.  
  35. #ifdef _ABI_SOURCE
  36.     memset (buf, 0, BUFFER);
  37. #else
  38.     bzero (buf, BUFFER);
  39. #endif
  40. #ifdef _ABI_SOURCE
  41.     memcpy (buf, string, strlen(string));
  42. #else
  43.     bcopy (string, buf, strlen(string));
  44. #endif
  45. #ifdef _ABI_SOURCE
  46.     rv = memcmp (string, buf, strlen(string));
  47. #else
  48.     rv = bcmp (string, buf, strlen(string));
  49. #endif
  50.     if ( rv == 0 )
  51.         printf ("Copied strings match\n");
  52. #ifdef _ABI_SOURCE
  53.     cp = strchr (buf, 'a');
  54. #else
  55.     cp = index (buf, 'a');
  56. #endif
  57.     if (cp != NULL)
  58.         printf ("Found character in string\n");
  59.     
  60. }
  61.